/**
 * This file is released under the GNU General Public License.
 * Refer to the COPYING file distributed with this package.
 *
 * Copyright (c) 2008-2009 WURFL-Pro srl
 */
package net.sourceforge.wurfl.core.handlers;

import net.sourceforge.wurfl.core.request.normalizer.UserAgentNormalizer;

import org.apache.commons.lang.StringUtils;

/**
 * Intercept all UAs containing "Samsung/SGH" or starting with one of the
 * following "SEC-", "Samsung", "SAMSUNG", "SPH", "SGH", "SCH"
 * 
 * @author WURFL-PRO SRL, Rome, Italy
 * @version $Id: SamsungHandler.java 1045 2009-03-09 15:52:53Z filippo.deluca $
 */
public class SamsungHandler extends Handler {

	public SamsungHandler(UserAgentNormalizer normalizer) {
		super(normalizer);
	}

	/**
	 * Checks given UA contains "Samsung/SGH" or starts with one of the
	 * following "SEC-", "Samsung", "SAMSUNG", "SPH", "SGH", "SCH"
	 */
	public boolean canHandle(String userAgent) {

		return (StringUtils.contains(userAgent, "Samsung/SGH")
				|| userAgent.startsWith("SEC-")
				|| userAgent.startsWith("Samsung")
				|| userAgent.startsWith("SAMSUNG")
				|| userAgent.startsWith("SPH") || userAgent.startsWith("SGH") || userAgent
				.startsWith("SCH"));
	}
}
